package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.CommodityBean;
import com.project.bean.OrderBean;
import com.project.mapper.IOrderMapper;
import com.project.service.IOrderService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class OrderServiceImpl implements IOrderService {
    @Autowired
    private IOrderMapper mapper;
    @Override
    public PageInfo<OrderBean> findByItem(Integer pageNO, String orName) {
        PageHelper.startPage(pageNO,2);
        PageInfo<OrderBean> pg = PageInfo.of(mapper.findByItem(orName));
        return pg;
    }

    @Override
    public void add(OrderBean order, List<CommodityBean> emList) {
        mapper.add(order);
        mapper.adds(order.getOrId(),emList);
    }

    @Override
    public OrderBean findById(Integer orId) {
        return mapper.findById(orId);
    }
}
